<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>


<script>
    var len = prompt("输入想要的金字塔的层数");
    for(var i = 1; i<=len;i++){
        var ensp = len - i;
        for(var j =1;j<=ensp ;j++){
            document.write("&ensp;");
        }
        var star = i * 2 - 1;
        for(var k = 1;k<=star;k++){
            document.write("*");
        }
        document.write("<br>")
    }
</script>
</body>
</html>